<template>
	<view class="page">
		<view class="doctor_list" v-if="list.length>0">
			<view class="card doctor_item" v-for="item in list" :key="item.doctorId"
				@click="gotoPage(`/pagesCommon/doctor/details?doctorId=${item.doctorId || item.id}`)">
				<view class="doctor_star">
					<view>
						<doctorInfo :item="item.doctorInfoRespVO"></doctorInfo>
					</view>
					<view class="info_star" @click="cancelMyFollow(item.doctorId)">
						<image class="icon" src="@/static/icon/doctor/love-fill-icon.png" mode="aspectFill"></image>
						<view>
							已关注
						</view>
					</view>
				</view>
				<view class="doctor_evaluate">
					<view class="evaluate star">
						<view class="icon">
							<image src="@/static/icon/doctor/star-icon.png" mode="widthFix"></image>
						</view>
						<view class="nums">
							{{item.doctorInfoRespVO.favorableCount || 0}}%
						</view>
					</view>
					<view class="evaluate">
						<view class="icon">
							接诊量
						</view>
						<view class="nums">
							{{item.doctorInfoRespVO.treatmentCount || ''}}
						</view>
					</view>
					<view class="evaluate">
						<view class="icon">
							回复
						</view>
						<view class="nums">
							{{item.doctorInfoRespVO.replySpeed || ''}}
						</view>
					</view>
				</view>
				<view class="doctor_capacity ellipsis-2">
					<text class="text">擅长:</text>
					{{item.doctorInfoRespVO.proficient || ''}}
				</view>
			</view>
		</view>
		<view class="no_thing" v-else>
			<image class="placeholder" src="@/static/images/noting.png" mode="scaleToFill"></image>
		</view>
	</view>
</template>

<script>
	import {
		queryMyFollow,
		cancelMyFollow
	} from '@/api/index.js'
	export default {
		data() {
			return {
				pageNo: 1,
				pageSize: 10,
				list: [],
				total: 0
			}
		},
		onLoad() {
			this.queryMyFollow()
		},
		methods: {
			gotoPage(url) {
				uni.navigateTo({
					url
				})
			},
			queryMyFollow() {
				queryMyFollow({
					pageNo: this.pageNo,
					pageSize: this.pageSize,
				}).then(res => {
					this.list = res.data.list
					this.total = res.data.total
				}).catch(err => {
					console.log(err)
				})
			},
			// 关注
			cancelMyFollow(doctorId) {
				cancelMyFollow({
					doctorId
				}).then(res => {
					this.queryMyFollow()
				}).then(() => {
					uni.showToast({
						icon: 'none',
						title: '取消关注',
					})
				}).catch(err => {
					console.log(err)
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.doctor_list {
		.doctor_item {
			margin-top: 30rpx;
			padding: 30rpx 20rpx;

			.doctor_star {
				display: flex;
				justify-content: space-between;

				.info_star {
					display: flex;
					align-items: center;
					justify-content: center;
					width: 130rpx;
					height: 60rpx;
					background-color: #4070FE;
					border-radius: 100rpx;
					font-size: 22rpx;
					color: #FFF;

					.icon {
						margin-right: 10rpx;
						width: 23rpx;
						height: 21rpx;
					}
				}
			}

			.doctor_evaluate {
				display: flex;
				align-items: center;
				margin: 30rpx 0;

				.evaluate {
					margin-right: 20rpx;
					display: flex;
					align-items: center;

					&.star {
						.nums {
							font-weight: bold;
							font-size: 26rpx;
							color: #F1AE34;
						}
					}

					.icon {
						margin-right: 10rpx;
						font-size: 22rpx;
						color: rgba(153, 153, 153, 0.8);

						image {
							width: 26rpx;
							height: 26rpx;
						}
					}

					.nums {
						font-weight: bold;
						font-size: 26rpx;
						color: #333333;
					}
				}
			}


			.doctor_capacity {
				color: #333;
				font-size: 26rpx;

				.text {
					display: inline-block;
					color: #999999;
					margin-right: 10rpx;
				}
			}
		}
	}
</style>